package org.javamap.overlays;

import org.javamap.*;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Stroke;

public class Road extends LineOverlay
{
	public Road() { setName("unnamed road"); }

	protected void drawOneLocation(Graphics2D g2d, Point p)
	{	
		// Only one location.  Draw a large white dot with a black outline.
		g2d.setColor(Color.WHITE);
		g2d.fillOval(
				p.x - NODE_SIZE/2 + 2,
				p.y - NODE_SIZE/2 + 2,
				NODE_SIZE,
				NODE_SIZE
		);
		g2d.setColor(COLOR_ROAD);
		g2d.drawOval(
				p.x - NODE_SIZE/2 + 2,
				p.y - NODE_SIZE/2 + 2,
				NODE_SIZE,
				NODE_SIZE
		);
	}

	protected void drawLineSegment(Graphics2D g2d, Point oldP, Point p)
	{
		g2d.setStroke(STROKE_OUTER_ROAD);
		g2d.setColor(COLOR_ROAD);
		g2d.drawLine(oldP.x, oldP.y, p.x, p.y);
		g2d.setStroke(STROKE_INNER_ROAD);
		g2d.setColor(Color.WHITE);
		g2d.drawLine(oldP.x, oldP.y, p.x, p.y);
	}
	
	protected void setupForDraw(Graphics2D g2d)
	{
		g2d.setColor(COLOR_ROAD);	
		//g2d.setStroke(STROKE_ROAD);
	}		
		
	private final static BasicStroke STROKE_OUTER_ROAD = new BasicStroke(
			3.0f,
			BasicStroke.CAP_ROUND,
			BasicStroke.JOIN_ROUND
	);
	private final static BasicStroke STROKE_INNER_ROAD = new BasicStroke(
			2.5f,
			BasicStroke.CAP_ROUND,
			BasicStroke.JOIN_ROUND
	);
	private final static Color COLOR_ROAD = Color.BLACK; // new Color(150, 80, 15);
	private final static int NODE_SIZE = 6;
}

